import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
//宝石与石头
public class Test {
    public int numJewelsInStones(String jewels,String stones){
        int count = 0;
        Set<Character> set = new HashSet<>();
        for (int i = 0;i < jewels.length();i++){
            char ch = jewels.charAt(i);
            set.add(ch);
        }
        for (int i = 0;i < stones.length();i++){
            char ch = stones.charAt(i);
            if (set.contains(ch)){
                count++;
            }
        }
        return count;
    }
    //复制带有指针的链表
    class Node{
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }
    public Node copyRandomList(Node head){
        Map<Node,Node> map = new HashMap<>();
        Node cur = head;
        while(cur != null){
            Node node = new Node(cur.val);
            map.put(cur,node);
            cur = cur.next;
        }
        cur = head;
        while (cur != null){
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
            cur = cur.next;
        }
        return map.get(head);
    }
}


